
#include<poisson.h>
#include<Arcroll.h>
void test(float* points,unsigned int* polygons, int p_size,int po_size)
{

	Viewer_World_Manager vwm;
	viewer_world_manager_init(&vwm);
	Viewer_World *vw=vwm.create_world(&vwm,NULL);

	add_default_somethings(vw);
	Node* n=vw->create_something(vw,"Faces");
	Viewer_Something*vs=(Viewer_Something*)(n->value);
	Viewer_Faces* vf=(Viewer_Faces*)(vs->evolution);
	vf->Data_rows=p_size;
	vf->Data_index_rows=po_size;
	vf->color_rows=vf->Data_index_rows;
	vf->set_color(vf,0.9,0.4,0.7,1.0);

	vf->normal_rows=vf->Data_index_rows;
	// vf->compute_normal(vf);

	vf->Data=points;
	vf->Data_index=polygons;		


	free_node(n);


	Viewer_Opengl_Interpreter voi;
	viewer_opengl_interpreter_initn(&voi,&vwm);
	voi.interpreter(&voi);


	viewer_opengl_interpreter_free(&voi);
	viewer_world_manager_free(&vwm);	
}

int main( int argc , char* argv[] )
{
	char* infile=NULL,*outfile=NULL;
	int depth;
	float pointweight;
	if(argc<=1)
	{
		infile="./bunny.points.ply";outfile="bunny.ply";
		depth=10;
		pointweight=0;
	}
	else
	{
		infile=argv[1];outfile=argv[2];
		depth=atoi(argv[3]);
		pointweight=atof(argv[4]);
	}
	
	float*points;unsigned int* polygons;
	int p_size,po_size;
	execute_poisson(infile,outfile,depth,pointweight,&points,&polygons,&p_size,&po_size);
	
	printf("%d %d\n",p_size,po_size);
	test(points,polygons,p_size,po_size );

	return 0;
}
